package com.jjsj.mall.shop.service;

import com.jjsj.mall.entity.OrderInfo;
import com.jjsj.mall.entity.UserAddress;
import com.jjsj.mall.entity.UserReceipt;
import com.jjsj.mall.service.OrderInfoService;
import com.jjsj.mall.service.UserAddressService;
import com.jjsj.mall.service.UserReceiptService;
import com.jjsj.weixin.entity.WxUser;
import com.jjsj.weixin.service.WxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class JJSJUserService {

    @Autowired
    private WxUserService wxUserService;

    @Autowired
    private UserAddressService wxUserAddressService;
    @Autowired
    private UserReceiptService wxUserReceiptService;

    @Autowired
    private OrderInfoService orderInfoService;


//    @DataSource(value = DataSourceType.MASTER)
    public void create(WxUser wxUser) {
        wxUserService.save(wxUser);
    }

    //    @DataSource(value = DataSourceType.MASTER)
    public void update(WxUser wxUser) {
        wxUserService.saveOrUpdate(wxUser);
    }

    //    @DataSource(value = DataSourceType.MASTER)
    public void createAddress(UserAddress address) {
        wxUserAddressService.save(address);
    }

    //    @DataSource(value = DataSourceType.MASTER)
    public void createReceipt(UserReceipt receipt) {
        wxUserReceiptService.save(receipt);
    }


    //    @DataSource(value = DataSourceType.MASTER)
    public WxUser selectUserByOpenId(String openId) {
        return wxUserService.getByOpenId(openId);
    }


    //    @DataSource(value = DataSourceType.MASTER)
    public void createOrder(OrderInfo orderInfo) {
        orderInfoService.save(orderInfo);
    }
}
